/*
// Definition for Employee.
class Employee {
public:
    int id;
    int importance;
    vector<int> subordinates;
};
*/

class Solution {
public:
    int getImportance(vector<Employee*> employees, int id) {
        unordered_map<int,Employee*>mp;
        for(int i=0;i<employees.size();i++){
            mp[employees[i]->id]=employees[i];
        }
        int ans=0;
        queue<Employee*> que;
        que.push(mp[id]);
        Employee* tmp;
        while(!que.empty()){
            tmp=que.front();
            que.pop();
            ans+=tmp->importance;
            for(int i=0;i<tmp->subordinates.size();i++){
                que.push(mp[tmp->subordinates[i]]);
            }
        }
        return ans;
    }
};